package com.mm.learn.designpatterns.factory;

/**
 * @author wdx
 * @date 2021年04月02日 9:30
 */
public class CoffeeStore {

    private CoffeeFactory factory;

    public CoffeeStore(CoffeeFactory factory){
        this.factory = factory;
    }


    public Coffee orderCoffee() {
        Coffee coffee = factory.createCoffee();
        coffee.addMilk();
        coffee.addSugar();
        return coffee;
    }

    public static void main(String[] args) {
        CoffeeFactory factory = new LatteCoffeeFactory();
        CoffeeStore store = new CoffeeStore(factory);
        Coffee coffee = store.orderCoffee();
        System.out.println(coffee.getName());
    }
}
